<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="idth=device-idth, initial-scale=1.0">
    <title>{$shared.title} - 主人：{$shared.author}</title>
    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <link rel="stylesheet" href="__PUBLIC__/markdown/css/editormd.css" />
    <!-- Sweet Alert -->
    <link href="__PUBLIC__/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated bounceInLeft article">
    <div class="row">
        <div class="col-lg-10 col-lg-offset-1">

            <div class="ibox">
                <div class="ibox-content">
                    <if condition="($shared['pin'] eq $_COOKIE['shared-pin']) || (!$shared['pin'])">
                        <div class="pull-right">
                            <if condition="$shared['type'] neq 2 && !$colled">
                                <button class="btn btn-info btn-xs coll" type="button">
                                    <i class="fa fa-star-half-o"></i>+收藏夹
                                </button>
                                <elseif condition="$colled" />
                                <button class="btn btn-danger btn-xs" type="button">
                                    <i class="fa fa-star-half-o"></i>已收藏夹
                                </button>
                            </if>


                            <if condition="$shared['type'] eq 2">
                                <button class="btn btn-warning btn-xs downLoad" type="button" path="{$shared.content}" fileName="{$shared.title|str_replace='分享了文件:','',###}">
                                    <i class="fa fa-download"></i> 下载文件
                                </button>
                            </if>
                            <button class="btn btn-info btn-xs" type="button">主人：{$shared.author}</button>
                            <button class="btn btn-success btn-xs" type="button" onclick="history.go(-1)">返回上一页</button>
                        </div>

                        <if condition="$shared['type'] eq 2">

                            <div class="text-center article-title">
                                <h1>
                                    {$shared.title}
                                </h1>
                                <small>分享时间 ：{$shared.time|beenTime}</small>
                            </div>
                            <div class="text-center" >
                                <i class="fa fa-file" style="font-size: 170px;"></i>
                            </div>
                            <hr>
                            <else />

                                <div class="text-center article-title">
                                    <h1>
                                        {$shared.title}
                                    </h1>
                                    <small>分享时间 ：{$shared.time|beenTime}</small>
                                </div>
                                <div id="sharedView">
                                    <textarea style="display:none;" name="editormd-markdown-doc">{$shared.content}</textarea>
                                </div>
                                <hr>
                            </if>
                    <else />
                        <div class="pull-right">
                            <button class="btn btn-warning btn-xs" type="button"> <i class="fa fa-key"></i>  主人已加密</button>
                            <button class="btn btn-info btn-xs" type="button">主人：{$shared.author}</button>
                            <button class="btn btn-success btn-xs" type="button" onclick="history.go(-1)">返回上一页</button>
                        </div>
                        <div class="text-center article-title">
                            <h1>
                                {$shared.title}
                            </h1>
                            <small>分享时间 ：{$shared.time|beenTime}</small>
                        </div>
                        <div class="text-center" id="unlock" style="cursor:pointer">
                            <i class="fa fa-key" style="font-size: 170px;"></i>
                        </div>
                        <hr>

                    </if>
                    <div class="row">
                        <div class="col-lg-12">
                            <notempty name="prev">
                                <div class="pull-left">
                                    <a href="/look?sid={$prev['id']}" class="btn "><i class="fa fa-angle-double-left"></i> {$prev.title}</a>
                                </div>
                            </notempty>
                            <notempty name="next">
                                <div class="pull-right">
                                    <a href="/look?sid={$next['id']}" class="btn "> {$next.title} <i class="fa fa-angle-double-right"></i></a>
                                </div>
                            </notempty>
                        </div>
                    </div>


                </div>
            </div>

        </div>
        <include file="Public/footer" />
    </div>
    <iframe id="iframe" src="" style="display: none;"></iframe>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/markdown/lib/marked.min.js"></script>
<script src="__PUBLIC__/markdown/lib/prettify.min.js"></script>
<script src="__PUBLIC__/markdown/lib/raphael.min.js"></script>
<script src="__PUBLIC__/markdown/lib/underscore.min.js"></script>
<script src="__PUBLIC__/markdown/lib/sequence-diagram.min.js"></script>
<script src="__PUBLIC__/markdown/lib/flowchart.min.js"></script>
<script src="__PUBLIC__/markdown/lib/jquery.flowchart.min.js"></script>
<script src="__PUBLIC__/markdown/editormd.js"></script>
<script src="__PUBLIC__/static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var sharedView;
        sharedView = editormd.markdownToHTML("sharedView", {
            htmlDecode      : "style,script,iframe",  // you can filter tags decode
            emoji           : true,
            taskList        : true,
            tex             : true,  // 默认不解析
            flowChart       : true,  // 默认不解析
            sequenceDiagram : true,  // 默认不解析
        });

        //下载文件
        $('.downLoad').click(function(){
            var path = $(this).attr('path');
            var name = $(this).attr('fileName');
            $('#iframe').attr('src',"{:U('Com/downfile')}?path="+path+"&name="+name);
        })

        //收藏
        $('.coll').click(function () {
            var url= window.location.href;
            var title ="{$shared['title']}";
            $.post("{:U('Com/coll')}",{content:url,name:title},function(data){
                if(data.status !== 'y'){
                    swal('操作失败!', "参数错误原因可能是程序没有获取到参数！", "warning");
                }else{
                    window.location.reload();
                }
            });

        });

        //判断是否是pin码
        $('#unlock').click(function () {
            swal({
                title: "解锁请向主人要pin码!",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                confirmButtonColor: "#DD6B55",
                cancelButtonText:"取消",
                confirmButtonText: "确定",
                animation: "slide-from-top",
                inputPlaceholder: "这里输入6位pin码！",
            },function(inputValue){
                if (inputValue === false) return false;
                if (inputValue.length !== 6){
                    swal("PIN码必须为6位");
                    return false;
                }else{
                    if(MD5(inputValue) == "{$shared['pin']|md5}"){
                        //保存pin码
                        Setcookie('shared-pin',inputValue);
                        window.location.reload();
                    }else{
                        swal("PIN码错误！");
                    }
                }
            });
        });

    })


</script>
</body>
</html>